<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 *
 * @package		Adminpro
 * @author		Tran Hoang Thien (thienhb12@gmail.com)
 * @copyright   PHP TEAM
 * @link		http://phpandmysql.net
 * @since		Version 1.0
 * @phone       0944418192
 *
 */
class Request extends MY_Controller {

	public function __construct(){
		parent:: __construct();
		$this->load->model('request_model');
		$this->load->helper('url');
		$this->load->library('form_validation');
	}

	public function index(){
		$request      = $this->input->post('request');
		$var          = array();
		$data         = array();
		$template	  = 'request/request';  
		if(isset($request)){
			$this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|xss_clean');
			$this->form_validation->set_rules('contents', 'contents', 'trim|required|xss_clean');
			$email    = fillter($this->input->post('email'));
			$contents = fillter($this->input->post('contents'));
			if($this->form_validation->run() == FALSE){
				$var['error'] = 1;
			}else{
				$var['error'] = 0;
				$this->request_model->save($id = false,array('r_email'=>$email,'r_contents' => $contents));
			}
			$var['content'] = $this->load->view($template,$data,true);
			exit(json_encode($var));
		}
	}

}

/* End of file index.php */
/* Location: ./application/modules/home/controllers/index.php */